package com.dkha.server;

import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import com.dkha.server.common.handler.MyMetaObjectHandler;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.dkha.server.controllers.WebSocketContral;

import java.net.InetSocketAddress;


@SpringBootApplication(exclude = {
        org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class},scanBasePackages = {"com.dkha.common", "com.dkha.server"})
@MapperScan("com.dkha.server.mappers")
@MapperScan("com.dkha.server.system.modules.log.dao")
@MapperScan("com.dkha.server.system.modules.sys.dao")
@EnableScheduling
public class FaceServerApplication {
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(FaceServerApplication.class);
        ConfigurableApplicationContext configurableApplicationContext = springApplication.run(args);
        //解决WebSocket不能注入的问题
        WebSocketContral.setApplicationContext(configurableApplicationContext);
    }

    /**
     * mybatis-plus自动注入插件
     *
     * @return
     */
    @Bean
    public MyMetaObjectHandler createMyMetaObjectHandler() {
        return new MyMetaObjectHandler();
    }


    /**
     * mybatis-plus执行效率插件
     * @return
     */
    //@Bean
    // 设置 dev test 环境开启
    //@Profile({"dev"})
    public PerformanceInterceptor performanceInterceptor() {
        return new PerformanceInterceptor();
    }

}
